// part1:C10:ex10.34.cpp
// use reverse_iterator to reverse a vector.
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
    if (argc != 2) 
    {
        cout << "usage:execise.txe in_file!" << endl;
        exit(-1);
    }

    ifstream in(argv[1]);
    if (!in) 
    {
        cout << "failed open input file!" << endl;
        exit(1);
    }

    vector<int> vi;
    int v;
    while (in >> v) 
    {
        vi.push_back(v);
    }

    for (auto r_iter = vi.crbegin(); r_iter != vi.crend();
        ++r_iter)
    {
        cout << *r_iter << " ";
    }
    cout << endl;
    
    return 0;
}